this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 100;
		coefficient = 100;
		top_pos = 0;
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		var scroll = $(window).scrollTop();
		
		var theImage = new Image();
		theImage.src = this.href;
		img_height = theImage.height;
		img_width = theImage.width;
		var win_height = $(window).height();
		
		if( img_height > win_height ) {
			coefficient = Math.floor(win_height * 100 / img_height);
		}
		
		top_pos = Math.floor(scroll + win_height / 2 - img_height * coefficient / 100 / 2);
		
		$("body").append("<p id='preview'><img id='full_image' src='"+ this.href +"' alt="+ this.t +" />"+ c +"</p>");
		$("#full_image")
			.css("height",(coefficient) + "%")
			.css("width",(coefficient) + "%");
		$("#preview")
			.css("top",(top_pos) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#full_image")
			.css("height",(coefficient) + "%")
			.css("width",(coefficient) + "%");
		$("#preview")
			.css("top",(top_pos) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
	
	$("#owl-demo").owlCarousel({
 
		autoPlay: 3000, //Set AutoPlay to 3 seconds
 
		items : 7,
		itemsDesktop : [1199,5],
		itemsDesktopSmall : [979,3] 
	});
});

$('#cancel_size').click(function(){
	$('.in_use').toggleClass( 'in_use', false );
	$('#size_block').find('input[type=checkbox]').attr('checked', false);
});

$('#ss_0').click(function(){
	if (this.checked) {
		$('.ss_chck').prop('checked', true);
		$('.ss_chck').parent().toggleClass( 'ss_in_use', true );
		$(this).parent().toggleClass( 'ss_in_use', true );
	} else {
		$(this).toggleClass( 'ss_in_use', false );
		$('.ss_in_use').toggleClass( 'ss_in_use', false );
		$('.ss_chck').prop('checked', false);
	}
});

$(':checkbox.ss_chck').change(function(){
	if (this.checked) {
		$(this).parent().toggleClass( 'ss_in_use', true );
		if (!$(':checkbox.ss_chck:not(:checked)').length) {
			$('#ss_0').prop('checked', true);
			$('#ss_0').parent().toggleClass( 'ss_in_use', true );
		}
	} else {
		$('#ss_0').parent().toggleClass( 'ss_in_use', false );
		$('#ss_0').prop('checked', false);
		$(this).parent().toggleClass( 'ss_in_use', false );
	}
});

$(':checkbox.s_chck').change(function(){
	if (this.checked) {
		$(this).parent().toggleClass( 'in_use', true );
	} else {
		$(this).parent().toggleClass( 'in_use', false );
	}
});

$(':text').keyup(function(){
	var the_text = $(this).val();
	var emptystr = /^\s*$/;
	if (!emptystr.test(the_text)) {
		$(this).toggleClass( 'in_use', true );
	} else {
		$(this).toggleClass( 'in_use', false );
	}
});